package com.qfjy.sign;
import com.qfjy.entity.Publock;
import com.qfjy.service.PublockService;
import com.qfjy.uitl.ResultCode;
import com.qfjy.uitl.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
public class SignController {

     @Autowired
    private PublockService publockService;
     @ResponseBody
    @RequestMapping("sign")
    public ResultJson sign(String uid){
        // System.out.println("222222222222"+uid);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Publock publock = new Publock();
        publock.setSignData(sdf.format(new Date()));
        publock.setId(Integer.parseInt(uid));
         publockService.insertSelective(publock);
         List<Publock> publocks = publockService.selectSignList(uid);
         String str="";
         for(int i=0;i<publocks.size();i++){
             str=publocks.get(i).getSignData()+",";
         }
         return new ResultJson(str, ResultCode.SUCCESS);
    }
}